<template>
    <van-nav-bar title="优惠券列表" left-text="" left-arrow @click-left="goBack" />

    <div id="couponlist">
        <div class="coupon_list">
            <div class="coupon_item" v-for="item in coupon">
                    <div class="item_content">
                        <router-link :to="{path: '/coupon/info', query: {cid: item.coupon.id}}">
                            <div class="left">
                            {{parseFloat(item.coupon.rate) * 100}}<span>折</span>
                            </div>
                            <div class="right">
                                <div>{{item.coupon.title}}</div>
                                <div>活动开始时间： {{item.coupon.createtime_text}}</div>
                                <div>活动开始时间： {{item.coupon.endtime_text}}</div>
                                <div>领取数量： {{item.coupon.total}} 张 每人限领1张</div>
                            </div>
                        </router-link>
                    </div>
                    <div class="item_btn">
                        <router-link class="right_btn" :to="{path: '/coupon/info', query: {cid: item.coupon.id}}">优惠详情</router-link>
                    </div>
                </div>
        </div>
    </div>
</template>
<script setup>
import { onBeforeMount } from 'vue';
const { proxy } = getCurrentInstance()
const LoginUser = reactive(proxy.$cookies.get('LoginUser') ? proxy.$cookies.get('LoginUser') : {})

const goBack = () => { proxy.$router.go(-1) }
let coupon = ref({})
onBeforeMount( () =>{
    getcoupon()
})

let getcoupon = async() => {
    let result = await Api.coupon({
        busid:LoginUser.id
    })
    if (result.code == 1){
        coupon.value = result.data.list
    }
}


</script>
<style scoped>
@import url("/assets/css/coupon_list.css");
@import url("/assets/css/coupon.css");
</style>